﻿<UserControl
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:Foundation="clr-namespace:SUMO.Foundation"
             xmlns:ctrls="clr-namespace:SUMO.MediaBrowser.Controls"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:im="clr-namespace:Microsoft.Expression.Interactivity.Media;assembly=Microsoft.Expression.Interactions" x:Class="SUMO.MediaBrowser.Controls.ImageMediaItemThumbnail"
             Width="160" Height="120" Loaded="UserControl_Loaded" >
	<UserControl.Resources>
		<Storyboard x:Name="ButtonsAppear">
			<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Buttons" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
				<EasingDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0">
					<EasingDoubleKeyFrame.EasingFunction>
						<CubicEase EasingMode="EaseOut"/>
					</EasingDoubleKeyFrame.EasingFunction>
				</EasingDoubleKeyFrame>
			</DoubleAnimationUsingKeyFrames>
		</Storyboard>
		<Storyboard x:Name="ButtonsHide">
			<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Buttons" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
				<EasingDoubleKeyFrame KeyTime="00:00:00.5000000" Value="55">
					<EasingDoubleKeyFrame.EasingFunction>
						<CubicEase EasingMode="EaseOut"/>
					</EasingDoubleKeyFrame.EasingFunction>
				</EasingDoubleKeyFrame>
			</DoubleAnimationUsingKeyFrames>
		</Storyboard>
		<Style x:Key="EditBtnStyle" TargetType="Button">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="Button">
						<Canvas x:Name="EditButton">
							<VisualStateManager.VisualStateGroups>
								<VisualStateGroup x:Name="FocusStates">
									<VisualState x:Name="Focused"/>
									<VisualState x:Name="Unfocused"/>
								</VisualStateGroup>
								<VisualStateGroup x:Name="CommonStates">
									<VisualState x:Name="Normal"/>
									<VisualState x:Name="MouseOver"/>
									<VisualState x:Name="Pressed"/>
									<VisualState x:Name="Disabled"/>
								</VisualStateGroup>
							</VisualStateManager.VisualStateGroups>
							<Image Height="26" Width="26" Source="../_Assets/edit-icon.png" Stretch="Fill"/>
							<ContentPresenter Canvas.Left="28" Canvas.Top="5"/>
						</Canvas>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
			<Setter Property="Foreground" Value="White"/>
		</Style>
		<Style x:Key="RevertBtnStyle" TargetType="Button">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="Button">
						<Canvas x:Name="RevertButton">
							<VisualStateManager.VisualStateGroups>
								<VisualStateGroup x:Name="FocusStates">
									<VisualState x:Name="Focused"/>
									<VisualState x:Name="Unfocused"/>
								</VisualStateGroup>
								<VisualStateGroup x:Name="CommonStates">
									<VisualState x:Name="Normal"/>
									<VisualState x:Name="MouseOver"/>
									<VisualState x:Name="Pressed"/>
									<VisualState x:Name="Disabled"/>
								</VisualStateGroup>
							</VisualStateManager.VisualStateGroups>
							<Image Height="26" Width="26" Source="../_Assets/revert-icon.png" Stretch="Fill"/>
							<ContentPresenter Canvas.Left="29" Canvas.Top="5"/>
						</Canvas>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
			<Setter Property="Foreground" Value="White"/>
		</Style>
	</UserControl.Resources>
    <!--ToolTipService.ToolTip="{Binding Path='', Converter={StaticResource TooltipMediaItemConverter},Mode=TwoWay }"-->
	<!--ToolTipService.ToolTip="{Binding Path='', Converter={StaticResource TooltipMediaItemConverter},Mode=TwoWay }"-->
	<!--ToolTipService.ToolTip="{Binding Path='', Converter={StaticResource TooltipMediaItemConverter},Mode=TwoWay }"-->
	<Grid x:Name="LayoutRoot" Background="White" Margin="2,2,2,2" Height="120" Width="160">
		<Border BorderThickness="1,1,1,1"  BorderBrush="{Binding DataModified, Converter={StaticResource ModificationBooleanToColorConverter}}">
            <Grid Margin="-1,-1,1,1" Width="160" Height="120" Background="#FF3D3D3D">
                <ctrls:LoadingControl VerticalAlignment="Center" HorizontalAlignment="Center" x:Name="Loading"  Margin="0"  />
                <Image Margin="0" x:Name="Folder" Source="../_Assets/folder.png" Visibility="Collapsed" MouseLeftButtonDown="Folder_MouseLeftButtonDown"/>
                <Grid>
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="MouseLeave">
                            <im:ControlStoryboardAction x:Name="ButtonMouseLeave" Storyboard="{StaticResource ButtonsHide}"/>
                        </i:EventTrigger>
                        <i:EventTrigger EventName="MouseEnter">
                            <im:ControlStoryboardAction x:Name="ButtonMouseEnter" Storyboard="{StaticResource ButtonsAppear}"/>
                        </i:EventTrigger>
                        <i:EventTrigger EventName="GotFocus">
                            <im:ControlStoryboardAction x:Name="ButtonGotFocus" Storyboard="{StaticResource ButtonsAppear}"/>
                        </i:EventTrigger>
                        <i:EventTrigger EventName="LostFocus">
                            <im:ControlStoryboardAction x:Name="ButtonLostFocus" Storyboard="{StaticResource ButtonsHide}"/>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                    <Image SizeChanged="Image_ImageOpened" 
			           Source="{Binding ItemData, Converter={StaticResource ByteImageConverter}, Mode=TwoWay}"
			           Margin="0" MouseLeave="Image_MouseLeave" MouseEnter="Image_MouseEnter"
			           MouseLeftButtonUp="Image_MouseLeftButtonUp" ImageOpened="Image_ImageOpened" x:Name="Thumb">
                    </Image>
                    <Grid x:Name="Buttons" Height="47" VerticalAlignment="Bottom" RenderTransformOrigin="0.5,0.5">
                        <Grid.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform/>
                                <SkewTransform/>
                                <RotateTransform/>
                                <TranslateTransform Y="55"/>
                            </TransformGroup>
                        </Grid.RenderTransform>
                        <Rectangle x:Name="ButtonBg" Fill="#58000000" StrokeThickness="0" Opacity="0.75"/>
                        <Button x:Name="EditBtn" HorizontalAlignment="Left" Margin="11,11,0,10" Style="{StaticResource EditBtnStyle}" Width="49" Content="Edit" Click="EditBtn_Click" />
                        <Button x:Name="RevertBtn" Margin="75,11,20,10" Style="{StaticResource RevertBtnStyle}" Content="Revert" Click="RevertBtn_Click" />
                    </Grid>
                </Grid>
            </Grid>
		</Border>
	</Grid>
</UserControl>